<?php
class ORMMail extends ORMBase {
  public function __construct() {
    parent::__construct('Mail');
  }

  public function __toEpObject($myManager, $epObject, $object) {
    require_once dirname(__FILE__) . '/ORMOrderProduce.class.php';
    $epObject->trackId = isset($object->trackId) ? $object->trackId : '';
    $epObject->createdDate = isset($object->createdDate) ? SimpleDate::toStamp($object->createdDate) : 0;
    $epObject->sdate = isset($object->sdate) ? SimpleDate::toStamp($object->sdate) : 0;
    $epObject->rdate = isset($object->rdate) ? SimpleDate::toStamp($object->rdate) : 0;
    $epObject->number = isset($object->number) ? $object->number : '';
    $epObject->company = isset($object->company) ? $object->company : '';
    $epObject->weight = isset($object->weight) ? $object->weight : 0;
    $epObject->recipient = isset($object->recipient) ? $object->recipient : '';
    $epObject->destination = isset($object->destination) ? $object->destination : '';
    $epObject->comment = isset($object->comment) ? $object->comment : '';
    if (isset($epObject->produces)) {
      $epObject->produces->removeAll();
      foreach ($object->produces as &$item) {
        $epObject->produces[] = $this->__getEpObject_4_lvl_1_object($myManager, $item, new ORMOrderProduce(), 'OrderProduce');
      }
    }
    return $epObject;
  }

  public function __toObject($myManager, $epObject, $object) {
    require_once dirname(__FILE__) . '/ORMOrderProduce.class.php';
    $object->id = $epObject->oid;
    $object->trackId = $epObject->trackId;
    $object->createdDate = SimpleDate::fromStamp($epObject->createdDate);
    $object->sdate = SimpleDate::fromStamp($epObject->sdate);
    $object->rdate = SimpleDate::fromStamp($epObject->rdate);
    $object->number = $epObject->number;
    $object->company = $epObject->company;
    $object->weight = $epObject->weight;
    $object->recipient = $epObject->recipient;
    $object->destination = $epObject->destination;
    $object->comment = $epObject->comment;
    $object->produces = array();
    if (isset($epObject->produces)) {
      foreach ($epObject->produces as &$item) {
        $object->produces[] = $this->__getObject_4_lvl_1_ep_object($myManager, $item, new ORMOrderProduce());
      }
    }
    return $object;
  }
}
?>
